#include <iostream>
#define N 100

using namespace std;

//average not accuarate enough

void read_matrix(int matrix[N][N], int row, int column){
int i, j;
for (i=0;i<row;i++)
    for(j=0;j<column;j++){
        cout<<"["<<i<<"]["<<j<<"]= ";
        cin>>matrix[i][j];}
}


int main(){
int row;
int column;
int matrix[N][N];
int i,j;
int sum=0;
int prod=1;
int elements=0;

cout<<"Type the number of rows: " ;
cin>>row;

cout<<"Type the number of columns: " ;
cin>>column;

read_matrix(matrix, row, column);

for(i=0;i<row;++i)
    for(j=0;j<column;++j)
        if(i>=j){
            sum += matrix[i][j];
            elements++;}
for(i=0;i<row;i++){
    for(j=0;j<column;j++)
			cout<<matrix[i][j]<<" ";
		cout<<endl;}

cout<<"The average of the elements above and below the diagonal is: " << (float)sum/elements<<endl;

return 0;
}
